package com.example.backgroundmanager.exception;

import com.example.backgroundmanager.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

public class GlobalExceptionHandler {
    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result handle(ServiceException se){ //如果抛出ServiceException,则用该方法
        return Result.error(se.getCode(),se.getMessage());
    }

}
